import Buff from '@/Buff';
import BuffUtil from '@/BuffUtil';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 蚀毒攻击
 **/
export default class BossSpell_PosionAttack extends AbilityBase {
    static instance: BossSpell_PosionAttack;
    buffType: AppBuffType = {
        id: 'buff_BossSpell_PosionAttack',
        art: this.art,
        name: this.abilityName,
        ubertip: this.ubertip,
        attribute: {
            受到治疗增强: -0.15,
            move_speed_p: -0.1,
        },
        stackCountMax: -1,
        dur: 7,
        targetAttach: 'origin',
        targetArt: 'Abilities\\Spells\\Human\\Banish\\BanishTarget.mdl',
        interval: 1,
        onInterval: this.onBuffInterval.bind(this),
        isDebuff: true,
    };
    onBuffInterval(buff: Buff) {
        let dmg = (200 + GetUnitState(buff.getParent(), UNIT_STATE_MAX_LIFE) * 0.025) * buff.stackCount;
        DamageSystemInstance.applyPoisionDamage(buff.getParent(), buff.getCaster(), dmg);
    }
    constructor(id: string = 'Ajt1') {
        super(id);
        BossSpell_PosionAttack.instance = this;
        this.init();
        // se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
        EventManager.onTakeAttack(this.onSpellEffect.bind(this));
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        BuffUtil.addBuff(target, this.buffType.id, source);
    }
    onSpellEffect(d: DamageEventData) {
        if (GetUnitAbilityLevel(d.source, this.id) == 0) return;
        this.cast(0, 0, d.source, d.target);
    }
}
